#ifndef __OSA_CONTROL_H__
#define __OSA_CONTROL_H__

#include <vxi11_user.h>
#include <string>

//#define __VXI11_ASCII__		//!< Flag for reading by ASCII format

const unsigned long OSA_TIMEOUT=60000; // in ms

#ifdef __VXI11_ASCII__
// ASCII: format = '-1.23456789E+001,...'
const unsigned long OSA_BUFFER_LEN=17*1001;
#else
// Binary: format = '#44004......'
const unsigned long OSA_BUFFER_LEN=1+1+4+4*1001+1;
#endif

class osa_control
{
  std::string device_ip;
  std::string device_name;
  CLINK clink;

  char trace_buffer[OSA_BUFFER_LEN];

  int status;
  void check_status(std::string message);

  void connect();

public:
  unsigned trace_no;
  unsigned wavelength_start;
  unsigned wavelength_stop;
  float resolution;
  float sensitivity;

  osa_control(std::string device_ip, std::string device_name);
  void initialize(unsigned wavelength_start, unsigned wavelength_stop, float sensitivity,float ref_level,float bw_res, unsigned trace_no);
  void get_trace(float *y,unsigned length);
  ~osa_control();
};

//void swap_float(float *y,unsigned length);

#endif


